//hien thi danh sach hoc sinh tu list<MarkModel>, cho giao vien chon va cho diem tung hoc sinh


package TruongNhaLib;

import java.util.List;

import www.truongnha.com.R;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class StdListAdapter extends ArrayAdapter<MarkModel> {
	private final List<MarkModel> list;
	private final Activity context;
	
	public StdListAdapter(Activity context, List<MarkModel> list) {
		super(context, R.layout.home_class_item, list);
		this.context =context;
		this.list = list;
	}
	static class ViewHolder{
		protected TextView name;
		protected TextView DOB;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent){
		View view = null;
		if(convertView == null){
			LayoutInflater inflator = context.getLayoutInflater();
			view = inflator.inflate(R.layout.home_class_item, null);
			final ViewHolder viewHolder = new ViewHolder();
			
			viewHolder.name = (TextView) view.findViewById(R.id.std_name);
			viewHolder.DOB = (TextView)view.findViewById(R.id.std_status);//status map to date of birth
			view.setTag(viewHolder);
		}else{
			view = convertView;
		}
		ViewHolder holder = (ViewHolder) view.getTag();
		holder.name.setText(list.get(position).getIndex()+". "+ list.get(position).getName());

		return view;
	}//end getView
}
